#ifndef RTSPSERVER1_H
#define RTSPSERVER1_H

#include <QObject>
#include <QTcpServer>
#include <QTcpSocket>
#include <QDebug>

#include "rtsp.h"

#define SERVER_PORT         8554
#define SERVER_RTP_PORT     55532
#define SERVER_RTCP_PORT    55533

class RtspServer1 : public QObject
{
    Q_OBJECT
public:
    explicit RtspServer1(QObject *parent = nullptr);
    ~RtspServer1();

public slots:
    void start();
    void OnNewConnection();
    void OnRecv();
    void OnMessage(QString recvMsg);
    void OnClosed();

    int handleCmd_OPTIONS(char* result, int cseq);
    int handleCmd_DESCRIBE(char* result, int cseq, char* url);
    int handleCmd_SETUP(char* result, int cseq, int clientRtpPort);
    int handleCmd_PLAY(char* result, int cseq);

private:
    QTcpServer *m_server;
    QTcpSocket *m_socket;

    QString clientIP;
    int clientPort;

    bool m_bConnected;
};

#endif // RTSPSERVER1_H
